<?php

require '../com.swiss.mooh.dao.impl/FileDaoImpl.php';
require '../com.swiss.mooh.service/FileContentServiceImpl.php';

$dispatcher = new FileDaoImpl();
$fileContentService = new FileContentServiceImpl($dispatcher);

$output_dir = "../../assets/images/uploads/files/";

$fileDesc = $_POST['descID'];

$listOfFileVO = $fileContentService->getFileByDescID($fileDesc);
for ($i = 0; $i < $listOfFileVO->Size(); $i++) {
    $filePath = $output_dir . $listOfFileVO->GetObj($i)->getFileName();
    if (file_exists($filePath)) {
        unlink($filePath);
        $fileContentService->deleteFileContentByID($listOfFileVO->GetObj($i)->getFileName());
    }
}
echo 200;

